<!--
* @description:新增轮胎使用记录
* @fileName: NewTireServiceRecord
* @author:李周蓬
* @date:2021-1-
* @后台人员:李周蓬
-->
<template>
  <div>
       <table>
        <tr>
          <td>车牌号：</td>
          <td>
            <el-select v-model="AddData.CarNumber" placeholder="请选择">
              <el-option
                v-for="item in bindData"
                :key="item.value"
                :label="item.License"
                :value="item.CarNumber"
              >
              </el-option>
            </el-select>
          </td>
        </tr>
        <tr>
          <td>轮胎品牌：</td>
          <td>
            <el-input
              v-model="AddData.TyreBrand"
              placeholder="请输入内容"
            ></el-input>
          </td>
        </tr>
        <tr>
          <td>规格：</td>
          <td>
            <el-input
              v-model="AddData.Specification"
              placeholder="请输入内容"
            ></el-input>
          </td>
        </tr>
        <tr>
          <td>数量：</td>
          <td>
            <el-input
              v-model="AddData.Num"
              placeholder="请输入内容"
            ></el-input>
          </td>
        </tr>
        <tr>
          <td>使用日期：</td>
          <td>
            <el-date-picker
              v-model="AddData.UseTime"
              type="date"
              placeholder="选择日期"
            >
            </el-date-picker>
          </td>
        </tr>
        <tr>
          <td>备注：</td>
          <td>
            <el-input
              v-model="AddData.Remark"
              placeholder="请输入内容"
            ></el-input>
          </td>
        </tr>
        <tr>
        <td colspan="2">
          <el-button type="primary" @click="add">提交</el-button>
          <el-button @click="go">取消</el-button>
        </td>
      </tr>
      </table>
  </div>
</template>

<script>
export default {
data() {
    return {
      AddData: {
        TyreNumber: "",
        TyreBrand: "",
        CarNumber: "",
        Specification: "",
        Num: "",
        UseTime: "",
        Remark: "",
      },
      bindData: [],
    };
  },
  methods: {
    bind() {
      this.$axios
        .get("https://localhost:44399/api/app/maintain/bind")
        .then((res) => {
          this.bindData = res.data.PageData;
          this.bindData.unshift({ License: "请选择" });
        });
    },
    add() {
      this.$axios
        .post(
          "https://localhost:44399/api/app/tyre/add-tyre",
          this.AddData
        )
        .then((res) => {
          if (res.data > 0) {
            this.$message({
              type: "success",
              message: "添加成功!",
            });
            this.$router.push("/TireServiceRecord");
          } else {
            this.$message({
              type: "error",
              message: "添加失败!",
            });
          }
        });
    },
    go() {
      this.$router.go(-1);
    },
  },
  created() {
    this.bind();
  },
}
</script>

<style>

</style>